#ifndef BPE_PHYSICS_WORLD_H
#define BPE_PHYSICS_WORLD_H
#include <boost/shared_array.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>
#include "../BPECollision/BPECollisionWorld.h"
#include "../BPECollision/BPECollisionData.h"
#include "../BPEIrrlichtWrapperClasses/BPEIrrlichtPhysicsObject.h"
#include "BPEPhysicsObject.h"



using namespace std;
using namespace boost;
class BPEPhysicsWorld{

private:

	shared_ptr<BPECollisionWorld> cWorld;
	
	vector<	shared_ptr<BPEPhysicsObject>	> bpePhysicsObjects;



	vector<	BPEVector3d > universalForces; //false assumpsion that drag(air resistance) is a force same for everyobject
	BPEVector3d universalSpeed; //(gravity)

	void simpleCollisionSolution(const vector<BPECollisionData> &collisionPairs);
	void fullCollisionSolution(const int &colliderCode1, const int &colliderCode2,BPEVector3d collisionNormal);


	void physicsRoutinePhase1(vector<bool> &onMove, vector<BPEVector3d> &speeds);
	void physicsRoutinePhase2(const vector<BPECollisionData> &collisionPairs,const vector<BPEVector3d> &fixSpeeds);

	void updateAllBoundingShapes();
	void updateBoundingShape(const int& objCode);

public:
	BPEPhysicsWorld();
	BPEPhysicsWorld(const BPEPoint3d &worldSize);
	
	void addPhysicsObject(shared_ptr<BPEPhysicsObject> &pObj);
	void setUniversalSpeed(const BPEVector3d &vect); //(gravity)
	void addUniversalForce(const BPEVector3d &vect);
	void resetUniversalForces();


	void physicsRoutine();

};

#endif